<template>
	<view>
		<image src="../../static/login/top3.png" mode="widthFix" class="top"></image>
		<image src="../../static/login/logo.jpg" mode="widthFix" class="logo"></image>
		<view class="desc">
			<text class="name">专业代驾 服务第一</text>
		</view>
		<button class="btn" @tap="wxLogin()">司机登陆</button>
		<view class="register-container">
			没有账号?
			<text class="link" @tap="toRegisterPage()">立即注册</text>
			<text class="link" @tap="text()">测试</text>
		</view>
		<text class="remark">小程序仅限于飞驰专车代驾使用,登录前请先进行微信注册,注册前请消息阅读注册需求和使用流程</text>
		<u-toast ref="uToast" />
	</view>
</template>

<script>


import {unix} from "dayjs";
import test from "../../uview-ui/libs/function/test";

export default {
  computed: {
    test() {
      return test
    }
  },
	data() {
		return {};
	},
	methods: {
    wxLogin(){
      let _this = this;
      wx.login({
        success (res) {
          if (res.code) {
            //发起网络请求
            console.log(res.code)
            //发送后端要用的json
            const param = {
              "code":res.code,
              "type":1
            }
            _this.post("/uaa/app/login",param,res=>{
              //console.log(res)
              if(res.data.data){
                uni.setStorageSync("tokenValue",res.data.data.token)
                uni.setStorageSync("userInfo",res.data.data)
                uni.switchTab({
                  url:"../workbench/workbench"
                });
              }else {
                console.log('登录失败！' + res.data.message)
              }

            })
          } else {
            console.log('登录失败！' + res.errMsg)
          }
        }
      })
    },

    toRegisterPage(){
      uni.navigateTo({
        url:"../register/register"
      })
    },

    text(){
      this.get("/uaa/app/login/test","",res=>{
        console.log(1)
      })
    }

	},
	onLoad: function() {

	}
};
</script>

<style lang="less">
@import url('login.less');
</style>
